<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="/js/jquery-3.1.1.min.js"></script>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css"
          integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap-theme.min.css"
          integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js"
            integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
            crossorigin="anonymous"></script>
    <script language="javascript" th:inline="javaScript">
        function preview(oper){
            if (oper < 10){
                bdhtml=window.document.body.innerHTML;//获取当前页的html代码
                sprnstr="<!--startprint"+oper+"-->";//设置打印开始区域
                eprnstr="<!--endprint"+oper+"-->";//设置打印结束区域
                prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+18); //从开始代码向后取html
                prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));//从结束代码向前取html
                window.document.body.innerHTML=prnhtml;
                window.print();
                window.document.body.innerHTML=bdhtml;
            } else {
                window.print();
            }
        }
    </script>
    <style type="text/css">
        body{
            font-family: 楷体;
            font-size: 13px;
            font-weight:bold;
        }
    </style>
</head>
<body>
<div class="container" style="width:7.5cm ">
    <!--startprint1-->

    <!--打印内容开始-->
    <div id=sty >
        <!--标头-->
        <div >
            <p style="text-align:center;">中山市成栈饼家</p>
            <p style="text-align:center;">*************</p>
            <p style="text-align:center;">** 月饼礼饼 **</p>
            <p style="text-align:center;">*************</p>
            时间: <span>[[${date}]]</span>
            <hr size="1" noshade="noshade" style="border:1px #cccccc dotted;">
            <table>
                <tr>
                    <td>种类</td>
                    <td>数量</td>
                    <td>价钱</td>
                </tr>
                <tr th:each="l:${itemList}">
                    <td style="width: 4.5cm" th:text="${l.nameProduct}">种类</td>
                    <td style="width: 1.5cm" th:text="${l.count}">数量</td>
                    <td style="width: 1.5cm" th:text="${l.count}*${l.priceProduct}">价钱</td>
                </tr>
            </table>
            <hr size="1" noshade="noshade" style="border:1px #cccccc dotted;">
            <p>总价:<span style="float:right;">[[${sumPrice}]]</span></p>
        </div>
    </div>
    <!--打印内容结束-->
    <!--endprint1-->
</div>
<!--打印内容结束-->
<!--endprint1-->
<button  onclick="preview(1)">开始打印</button>

</body>
</html>